<?php
	function Query() {
		require("../../inc_trost/mydb_substance.inc");
		$db = mysql_connect($dbhost, $dbuser, $dbpass);
		if (!$db) {echo("db connection failed!");}
		if (!mysql_select_db($dbname)) {echo("selecting db name failed - top");}
		$time = time();
		$day = 86400;
		$query = "
			SELECT artname, titname, forname, labname, wsale, pic, sound, description, cracked_url, date, site
			FROM artist, title, format, label
			WHERE aid=artist.id	AND fid=format.id AND lid=label.id AND date>($time-50*$day) AND site<>0
			ORDER BY artname, titname
		";
		$res_array = mysql_query($query);
		if (!$res_array) {
			echo "<p>Error retrieving data for variable</p>";
			exit();
		}
		return $res_array;
	}

$array = Query();
$row = mysql_fetch_array($array, MYSQL_ASSOC);
print_r($row);
echo "<br><br>";

foreach($row as $key => $value) {
	echo "key: ".$key." - value: ".$value."<br>";
}
?>